/**
 * 
 */
package com.youxin.busfoundation.model;

import java.util.Date;
import java.util.List;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.youxin.busfoundation.common.GlobalConfig;
import com.youxin.busfoundation.common.es.bean.ContactBean;
import com.youxin.busfoundation.enums.FollowLeadsStatus;
import com.youxin.foundation.utils.DateUtil;
import com.youxin.foundation.utils.StringUtils;

/**
 * 线索列表展示Model
 * 
 * @description
 * @author yingde.cao
 * @date 2017年12月14日
 * @version 1.0
 */
public class EntCluePoolBean extends BaseEntCluePool {
	/**
	 * 线索状态展示
	 * 
	 * @description
	 * @return
	 */
	@JsonProperty("status_name")
	public String getStatusName() {
		// if (getStatus().shortValue() ==
		// FollowLeadsStatus.UnFollow.getValue()) {
		// return viewStatus == 0 ? "未查看" : "已查看";
		// }
		return FollowLeadsStatus.stringValue(getStatus());
	}

	@JsonProperty("create_time")
	public String getCreateTime() {
		return DateUtil.dateToString(new Date(getAddTime()), "yyyy-MM-dd");
	}

	@JsonProperty("industry_name")
	private String industryName;

	@JsonProperty("enterprise_manager")
	private short enterpriseManager;

	@JsonProperty("scale_name")
	private String scaleName;

	@JsonProperty("contact_number")
	private String contactNumber;

	@JsonProperty("short_name")
	private String shortName;

	@JsonProperty("view_status")
	private int viewStatus;

	public int getViewStatus() {
		return viewStatus;
	}

	public void setViewStatus(int viewStatus) {
		this.viewStatus = viewStatus;
	}

	@JsonIgnore
	private int contactNo;

	// private List<ContactBean> contacts;
	//
	// public List<ContactBean> getContacts() {
	// return contacts;
	// }
	//
	// public void setContacts(List<ContactBean> contacts) {
	// this.contacts = contacts;
	// }

	public int getContactNo() {
		return contactNo;
	}

	public short getEnterpriseManager() {
		Short type = getMemberType();
		return type == null ? 0 : type.shortValue();
	}

	public void setEnterpriseManager(short enterpriseManager) {
		this.enterpriseManager = enterpriseManager;
	}

	public void setContactNo(int contactNo) {
		this.contactNo = contactNo;
	}

	public String getIndustryName() {
		return StringUtils.isNullSetEmpty(industryName);
	}

	public void setIndustryName(String industryName) {
		this.industryName = industryName;
	}

	public String getScaleName() {
		return StringUtils.isNullSetEmpty(scaleName);
	}

	public void setScaleName(String scaleName) {
		this.scaleName = scaleName;
	}

	public String getContactNumber() {
		return contactNo + "个";
	}

	public void setContactNumber(String contactNumber) {
		this.contactNumber = contactNumber;
	}

	@JsonProperty("follow_time")
	public String getFollowTime() {
		int leadStatus = getStatus().shortValue();
		if (leadStatus == FollowLeadsStatus.UnFollow.getValue()) {
			return "";
		}
		Date date = new Date(getCurrentFollowTime());
		Date lastDate = null;
		if (leadStatus == FollowLeadsStatus.DealDone.getValue()) {
			lastDate = new Date(getUpdateTime());
		} else {
			lastDate = new Date();
		}
		long diff = DateUtil.getTimeDiff(date, lastDate);
		if (diff <= 0) {
			return "";
		}
	    long days=diff/GlobalConfig.DAYS_MILLISECONDS;
	    if(diff%GlobalConfig.DAYS_MILLISECONDS>0)
	    {
	    	days+=1;
	    }
		return StringUtils.isNullSetEmpty(days+"天");		
	}

	public String getShortName() {
		return StringUtils.isNullSetEmpty(shortName);
	}

	public void setShortName(String shortName) {
		this.shortName = shortName;
	}

}
